package com.qf.iostream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileCopyByte {
	
	public static void main(String[] args) {
		//2.字节流文件拷贝
		String inputPath = "D:\\Workspace\\Practice\\src\\writeTest01";
		
		String outputPath ="D:\\Workspace\\Practice\\src\\copyWriteByByte.txt";
		
		FileCopyByteByStream(inputPath,outputPath);
		
		
	}
	public static void FileCopyByteByStream(String inputPath,String outputPath) {
		
		try {
			//文件对象；路径
			File in = new File(inputPath);
			
			File out = new File(outputPath);
			
			//读入文件
			FileInputStream fileInput = new FileInputStream(in);
			//输出文件
			FileOutputStream fileOutput = new FileOutputStream(out,true);
			
			
			//开始拷贝文件
			byte bs[] = new byte[1024*10];
			int len =-1;
			
			while((len=fileInput.read(bs))!=-1) {
				//注意这里，不是system调用（system是打印读取文件内容），这里直接把字节流写入
				fileOutput.write(bs,0,len);
				
				
			}
			
			
		}catch(IOException e) {
			
			System.out.println("文件读取异常...");
			
			
			
		}
		
		
	}

}
